# Mike Reid (PiX64)

import mc, sage

def favListToListItems(list):
	items = mc.ListItems()
	counter = 1
	for fav in list:
		item = mc.ListItem(mc.ListItem.MEDIA_VIDEO_EPISODE)
		item.SetProperty('position', str(counter))
		item.SetProperty('FavoriteID', str(fav['FavoriteID']))
		item.SetLabel(fav['FavoriteTitle'])
		items.append(item)
		counter += 1
	return items
	
def favObjToItems(list):
	fav = list
	#print fav
	item = mc.ListItem(mc.ListItem.MEDIA_VIDEO_EPISODE)
	#item.SetProperty('FavoriteID', fav['FavoriteID']))
	#item.SetLabel(fav['FavoriteTitle'])
	if (fav['IsReRunsOnly'] == 'True'):
		item.SetProperty('IsFirstRunsAndReRuns', 'ReRuns')
	elif (fav['IsFirstRuns'] == 'True'):
		item.SetProperty('IsFirstRunsAndReRuns', 'First Runs')
	else:
		item.SetProperty('IsFirstRunsAndReRuns','First Runs & ReRuns')
	#item.SetProperty('IsFirstRunsAndReRuns', str(fav['IsFirstRunsAndReRuns']))
	#item.SetProperty('IsReRunsOnly', str(fav['IsReRunsOnly']))
	#item.SetProperty('IsFirstRuns', str(fav['IsFirstRuns']))
	#item.SetProperty('IsReRuns', str(fav['IsReRuns']))
	item.SetProperty('FavoriteChannel', str(fav['FavoriteChannel']))
	item.SetProperty('IsAutoDelete', str(fav['IsAutoDelete']))
	item.SetProperty('KeepAtMost', str(fav['KeepAtMost']))
	item.SetProperty('FavoriteTimeslot', str(fav['FavoriteTimeslot']))
	item.SetProperty('FavoriteQuality', str(fav['FavoriteQuality']))
	item.SetProperty('FavoriteAutomaticConversionFormat', str(fav['FavoriteAutomaticConversionFormat']))
	#item.SetProperty('FavoriteAutomaticConversionDestination', str(fav['FavoriteAutomaticConversionDestination']))
	item.SetProperty('FavoriteKeyword', str(fav['FavoriteKeyword']))
	return item
	